module tag_data

entity Tag {
	name		::	String	(id)
	tgentries	->	List<TagEntry>
	popularity	::	Int // equivalent to bmentries.length
	
	function tgentries_add(tgentry: TagEntry) {
	  this.tgentries.add(tgentry);
	  this.popularity := this.tgentries.length;
	}
	
	function tgentries_remove(tgentry: TagEntry) {
	  this.tgentries.remove(tgentry);
	  this.popularity := this.tgentries.length;
	}
	
	function tgentries_fromuser(u: User) : TagEntry {
	  for(tgentry: TagEntry in this.tgentries) {
	    if(tgentry.user == u) {
	      return tgentry;
	    }
	  }
	  return null;
	}
}

